package com.offcn.user.controller;

import com.offcn.user.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "用户模块中的controller")
public class UserDemoController {

    @ApiOperation("show方法，用来显示用户信息")
    @ApiImplicitParam(name="name",value="用户的用户名",required = true)
    @GetMapping("/show")
    public String show(String name){
        return "show user's info,name = " + name;
    }

    @PostMapping("/addUser")
    public String addUser(@RequestBody User user){
        return "添加的用户信息:" + user.toString();
    }

    @PostMapping("/addUser1")
    public String addUser(String name,Integer age){
        User user = new User(name,age);
        return "添加的用户信息:" + user.toString();
    }
}
